# -*- coding: utf-8 -*-
"""
Module Description:
Date: 2017/1/9
Author:FQ
"""
from framework.dal.dal_adapters.base import BaseAdapter
from utils.json_utils import dumps, loads
from utils import json_utils as json
from datetime import timedelta
from framework.dal.gameconfig.game_env import get_config_env_set
from utils.time_utils import has_pass_time


class OrderSendAdapter(BaseAdapter):
    """
    TbOrderSend 适配器
    """

    def asdict(self):
        return {'OrderId': self.order_id,
                'RoleGuid': self.role_guid,
                'GameId': self.game_id,
                'ServerType': self.server_type,
                'ServerId': self.server_id,
                'OrderType': self.order_type,
                'Title': self.title,
                'Price': self.price,
                'NeedTime': self.need_time,
                'SafePrice': self.safe_price,
                'QuickPrice': self.quick_price,
                'GameAccount': self.game_account,
                'GamePassword': self.game_password,
                'GameNickName': self.game_nickname,
                'Mobile': self.mobile,
                'GameDes': self.game_des,
                'CreateTime': self.create_time,
                }

    @property
    def game_id(self):
        return self._record.GameId

    @game_id.setter
    def game_id(self, val):
        self._record.GameId = val

    @property
    def server_type(self):
        return self._record.ServerType

    @server_type.setter
    def server_type(self, val):
        self._record.ServerType = val

    @property
    def server_id(self):
        return self._record.ServerId

    @server_id.setter
    def server_id(self, val):
        self._record.ServerId = val

    @property
    def order_type(self):
        return self._record.OrderType

    @order_type.setter
    def order_type(self, val):
        self._record.OrderType = val

    @property
    def title(self):
        return self._record.Title

    @title.setter
    def title(self, val):
        self._record.Title = val

    @property
    def price(self):
        return self._record.Price

    @price.setter
    def price(self, val):
        self._record.Price = val

    @property
    def need_time(self):
        return self._record.NeedTime

    @need_time.setter
    def need_time(self, val):
        self._record.NeedTime = val

    @property
    def safe_price(self):
        return self._record.SafePrice

    @safe_price.setter
    def safe_price(self, val):
        self._record.SafePrice = val

    @property
    def quick_price(self):
        return self._record.QuickPrice

    @quick_price.setter
    def quick_price(self, val):
        self._record.QuickPrice = val

    @property
    def game_account(self):
        return self._record.GameAccount

    @game_account.setter
    def game_account(self, val):
        self._record.GameAccount = val

    @property
    def game_password(self):
        return self._record.GamePassword

    @game_password.setter
    def game_password(self, val):
        self._record.GamePassword = val

    @property
    def game_nickname(self):
        return self._record.GameNickName

    @game_nickname.setter
    def game_nickname(self, val):
        self._record.GameNickName = val

    @property
    def mobile(self):
        return self._record.Mobile

    @mobile.setter
    def mobile(self, val):
        self._record.Mobile = val

    @property
    def game_des(self):
        return self._record.GameDes

    @game_des.setter
    def game_des(self, val):
        self._record.GameDes = val

    @property
    def create_time(self):
        return self._record.CreateTime

    @create_time.setter
    def create_time(self, val):
        self._record.CreateTime = val

    @property
    def order_id(self):
        return self._record.OrderId

    @order_id.setter
    def order_id(self, val):
        self._record.OrderId = val

    @property
    def role_guid(self):
        return self._record.RoleGuid

    @role_guid.setter
    def role_guid(self, val):
        self._record.RoleGuid = val


class RoleAdapter(BaseAdapter):
    """
    TbRole 适配器
    """

    def asdict(self):
        return {
            'RoleGuid': self.role_guid,
            'Sex': self.sex,
            'NickName': self.nick_name,
            'RoleLv': self.role_lv,
            'RoleExp': self.role_exp,
            'Mobile': self.mobile,
            'Head': self.head,
            'LastEnterTime': self.last_enter_time,
            'UserStatus': self.user_status,
            'MatchTimes': self.match_times,
            'CreateTime': self.create_time,
            'Account': self.account,
            'Password': self.password,
            'AffairId': self.affair_id,
            'ServiceAffairId': self.service_affair_id,
            'ServiceTimes': self.service_times,
            'ServiceTime': self.service_time,
            'Amount': self.amount,
            'ServiceLv': self.service_lv,
            'GameServerDict': self.game_server_dict,
            'IsService': self.is_service,
        }

    @property
    def is_service(self):
        return self._record.IsService

    @is_service.setter
    def is_service(self, val):
        self._record.IsService = val

    @property
    def service_affair_id(self):
        return self._record.ServiceAffairId

    @service_affair_id.setter
    def service_affair_id(self, val):
        self._record.ServiceAffairId = val

    @property
    def service_times(self):
        return self._record.ServiceTimes

    @service_times.setter
    def service_times(self, val):
        self._record.ServiceTimes = val

    @property
    def service_time(self):
        return self._record.ServiceTime

    @service_time.setter
    def service_time(self, val):
        self._record.ServiceTime = val

    @property
    def amount(self):
        return self._record.Amount

    @amount.setter
    def amount(self, val):
        self._record.Amount = val

    @property
    def service_lv(self):
        return self._record.ServiceLv

    @service_lv.setter
    def service_lv(self, val):
        self._record.ServiceLv = val

    @property
    def game_server_dict(self):
        return json.loads(self._record.GameServerDict)

    @game_server_dict.setter
    def game_server_dict(self, val):
        self._record.GameServerDict = json.dumps(val)

    @property
    def affair_id(self):
        return self._record.AffairId

    @affair_id.setter
    def affair_id(self, val):
        self._record.AffairId = val

    @property
    def password(self):
        return self._record.Password

    @password.setter
    def password(self, val):
        self._record.Password = val

    @property
    def account(self):
        return self._record.Account

    @account.setter
    def account(self, val):
        self._record.Account = val

    @property
    def create_time(self):
        return self._record.CreateTime

    @create_time.setter
    def create_time(self, val):
        self._record.CreateTime = val

    @property
    def match_times(self):
        return self._record.MatchTimes

    @match_times.setter
    def match_times(self, val):
        self._record.MatchTimes = val

    @property
    def user_status(self):
        return self._record.UserStatus

    @user_status.setter
    def user_status(self, val):
        self._record.UserStatus = val

    @property
    def last_enter_time(self):
        return self._record.LastEnterTime

    @last_enter_time.setter
    def last_enter_time(self, val):
        self._record.LastEnterTime = val

    @property
    def head(self):
        return self._record.Head

    @head.setter
    def head(self, val):
        self._record.Head = val

    @property
    def mobile(self):
        return self._record.Mobile

    @mobile.setter
    def mobile(self, val):
        self._record.Mobile = val

    @property
    def role_exp(self):
        return self._record.RoleExp

    @role_exp.setter
    def role_exp(self, val):
        self._record.RoleExp = val

    @property
    def role_lv(self):
        return self._record.RoleLv

    @role_lv.setter
    def role_lv(self, val):
        self._record.RoleLv = val

    @property
    def nick_name(self):
        return self._record.NickName

    @nick_name.setter
    def nick_name(self, val):
        self._record.NickName = val

    @property
    def sex(self):
        return self._record.Sex

    @sex.setter
    def sex(self, val):
        self._record.Sex = val

    @property
    def role_guid(self):
        return self._record.RoleGuid

    @role_guid.setter
    def role_guid(self, val):
        self._record.RoleGuid = val


class SeatAdapter(BaseAdapter):
    """
    TbSeat 适配器
    """

    def asdict(self):
        return {
            'RoleGuid': self.role_guid,
            'ServiceRoleGuid': self.service_role_guid,
            'SeatId': self.seat_id,
        }

    @property
    def role_guid(self):
        return self._record.RoleGuid

    @role_guid.setter
    def role_guid(self, val):
        self._record.RoleGuid = val

    @property
    def service_role_guid(self):
        return self._record.ServiceRoleGuid

    @service_role_guid.setter
    def service_role_guid(self, val):
        self._record.ServiceRoleGuid = val

    @property
    def seat_id(self):
        return self._record.SeatId

    @seat_id.setter
    def seat_id(self, val):
        self._record.SeatId = val


class PayRecordAdapter(BaseAdapter):
    """
    TbPayRecord 适配器
    """

    def asdict(self):
        return {
            'RoleGuid': self.role_guid,
            'OrderId': self.order_id,
            'Amount': self.amount,
            'OrderStatus': self.order_status,
            'CreateTime': self.create_time,
            'RelationAffairId': self.relation_affair_id,

        }
    @property
    def relation_affair_id(self):
        return self._record.RelationAffairId

    @relation_affair_id.setter
    def relation_affair_id(self, val):
        self._record.RelationAffairId = val

    @property
    def create_time(self):
        return self._record.CreateTime

    @create_time.setter
    def create_time(self, val):
        self._record.CreateTime = val

    @property
    def order_status(self):
        return self._record.OrderStatus

    @order_status.setter
    def order_status(self, val):
        self._record.OrderStatus = val

    @property
    def role_guid(self):
        return self._record.RoleGuid

    @role_guid.setter
    def role_guid(self, val):
        self._record.RoleGuid = val

    @property
    def order_id(self):
        return self._record.OrderId

    @order_id.setter
    def order_id(self, val):
        self._record.OrderId = val

    @property
    def amount(self):
        return self._record.Amount

    @amount.setter
    def amount(self, val):
        self._record.Amount = val


class RoleAffairAdapter(BaseAdapter):
    """
    TbRoleAffair 适配器
    """

    def asdict(self):
        return {
            'RoleGuid': self.role_guid,
            'AffairId': self.affair_id,
            'SeatId': self.seat_id,
            'ServiceRoleGuid': self.sevice_role_guid,
            'FavoriteLv': self.favorite_lv,
            'Content': self.content,
            'EndTime': self.end_time,
            'AffairStatus': self.affair_status,
            'CreateTime': self.create_time,
        }

    @property
    def affair_status(self):
        return self._record.AffairStatus

    @affair_status.setter
    def affair_status(self, val):
        self._record.AffairStatus = val

    @property
    def role_guid(self):
        return self._record.RoleGuid

    @role_guid.setter
    def role_guid(self, val):
        self._record.RoleGuid = val

    @property
    def affair_id(self):
        return self._record.AffairId

    @affair_id.setter
    def affair_id(self, val):
        self._record.AffairId = val

    @property
    def seat_id(self):
        return self._record.SeatId

    @seat_id.setter
    def seat_id(self, val):
        self._record.SeatId = val

    @property
    def sevice_role_guid(self):
        return self._record.ServiceRoleGuid

    @sevice_role_guid.setter
    def sevice_role_guid(self, val):
        self._record.ServiceRoleGuid = val

    @property
    def favorite_lv(self):
        return self._record.FavoriteLv

    @favorite_lv.setter
    def favorite_lv(self, val):
        self._record.FavoriteLv = val

    @property
    def content(self):
        return self._record.Content

    @content.setter
    def content(self, val):
        self._record.Content = val

    @property
    def end_time(self):
        return self._record.EndTime

    @end_time.setter
    def end_time(self, val):
        self._record.EndTime = val

    @property
    def create_time(self):
        return self._record.CreateTime

    @create_time.setter
    def create_time(self, val):
        self._record.CreateTime = val


class ServiceRoleAffairAdapter(BaseAdapter):
    """
    TbServiceRoleAffair 适配器
    """

    def asdict(self):
        return {
            'RoleGuid': self.role_guid,
            'AffairId': self.affair_id,
            'LockSeatId': self.lock_seat_id,
            'ServiceRoleList': self.service_role_list,
            'SignTime': self.sign_time,
            'EndTime': self.end_time,
            'Reward': self.reward,
            'AffairStatus': self.affair_status,
        }
    @property
    def affair_status(self):
        return self._record.AffairStatus

    @affair_status.setter
    def affair_status(self, val):
        self._record.AffairStatus = val

    @property
    def reward(self):
        return self._record.Reward

    @reward.setter
    def reward(self, val):
        self._record.Reward = val

    @property
    def lock_seat_id(self):
        return self._record.LockSeatId

    @lock_seat_id.setter
    def lock_seat_id(self, val):
        self._record.LockSeatId = val

    @property
    def service_role_list(self):
        return json.loads(self._record.ServiceRoleList)

    @service_role_list.setter
    def service_role_list(self, val):
        self._record.ServiceRoleList = json.dumps(val)

    @property
    def sign_time(self):
        return self._record.SignTime

    @sign_time.setter
    def sign_time(self, val):
        self._record.SignTime = val

    @property
    def end_time(self):
        return self._record.EndTime

    @end_time.setter
    def end_time(self, val):
        self._record.EndTime = val

    @property
    def role_guid(self):
        return self._record.RoleGuid

    @role_guid.setter
    def role_guid(self, val):
        self._record.RoleGuid = val

    @property
    def affair_id(self):
        return self._record.AffairId

    @affair_id.setter
    def affair_id(self, val):
        self._record.AffairId = val
